//
//  XDMangaStarsController.m
//  XDEducation
//
//  Created by Ethan on 2017/5/15.
//  Copyright © 2017年 apple. All rights reserved.
//

#import "XDMangaStarsController.h"
#import "XDColorHeaderFile.h"
#import "XDConstantHeaderFile.h"
#import "WebViewController.h"
#import "XDButton.h"
@interface XDMangaStarsController ()
@property (nonatomic,strong) UIButton *oneButton;
@property (nonatomic,strong) UIButton *towButton;
@property (nonatomic,strong) UIButton *threeButton;
@property (nonatomic,strong) NSMutableArray *dataSource;
@end

@implementation XDMangaStarsController
- (NSMutableArray *)dataSource {
    
    if (_dataSource == nil) {
        self.dataSource = [NSMutableArray array];
    }
    return _dataSource;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = self.nameTitle;
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self setUpSuperViews];

}


- (void)setUpSuperViews{
    
    UIView *grayView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight *11/1334)];
    grayView.backgroundColor =  UIColor(232, 232, 234);
    [self.view addSubview:grayView];

    //爱的画画
    self.oneButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
    self.oneButton.frame = CGRectMake(0,kScreenHeight *44/1334,kScreenWidth/3,kScreenHeight *150/1334);
//        self.oneButton.backgroundColor = [UIColor redColor];
    [self.oneButton setImage:[UIImage imageNamed:@"adhh_icon"] forState:(UIControlStateNormal)];
    [self.oneButton setImage:[UIImage imageNamed:@"adhh_icon"] forState:(UIControlStateHighlighted)];
    UILabel *oneLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.oneButton.frame.origin.x, self.oneButton.frame.origin.y + self.oneButton.frame.size.height + kScreenHeight *26/1334, self.oneButton.frame.size.width, kScreenHeight * 28/1334)];
    oneLabel.text = @"爱的画画";
    oneLabel.font = [UIFont systemFontOfSize:14];
    oneLabel.textAlignment = NSTextAlignmentCenter;
//    oneLabel.backgroundColor = [UIColor redColor];
    [self.view addSubview:oneLabel];
    self.oneButton.tag = 201;
    [self.dataSource addObject:self.oneButton];
    [self.oneButton addTarget:self action:@selector(allAction:) forControlEvents:(UIControlEventTouchUpInside)];
    
    [self.view addSubview:self.oneButton];
    
    
    //故事锦集
    self.towButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
    self.towButton.frame = CGRectMake(self.oneButton.frame.origin.x + self.oneButton.frame.size.width,self.oneButton.frame.origin.y,self.oneButton.frame.size.width,self.oneButton.frame.size.height);
    [self.towButton setImage:[UIImage imageNamed:@"aqjk_icon"] forState:(UIControlStateNormal)];
    [self.towButton setImage:[UIImage imageNamed:@"aqjk_icon"] forState:(UIControlStateHighlighted)];
    self.towButton.tag = 202;
    [self.dataSource addObject:self.towButton];
    [self.towButton addTarget:self action:@selector(allAction:) forControlEvents:(UIControlEventTouchUpInside)];
    
//        self.towButton.backgroundColor = [UIColor orangeColor];
    [self.view addSubview:self.towButton];
    
    UILabel *towLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.towButton.frame.origin.x, oneLabel.frame.origin.y, self.towButton.frame.size.width, oneLabel.frame.size.height)];
//    towLabel.backgroundColor = [UIColor orangeColor];
    towLabel.text = @"故事锦集";
    towLabel.font = [UIFont systemFontOfSize:14];
    towLabel.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:towLabel];
    
    //    安全健康
    self.threeButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
    self.threeButton.frame = CGRectMake(self.towButton.frame.origin.x + self.towButton.frame.size.width,self.towButton.frame.origin.y,self.towButton.frame.size.width,self.towButton.frame.size.height);
    [self.threeButton setImage:[UIImage imageNamed:@"gsjj_icon"] forState:(UIControlStateNormal)];
    [self.threeButton setImage:[UIImage imageNamed:@"gsjj_icon"] forState:(UIControlStateHighlighted)];
    self.threeButton.tag = 203;
    [self.dataSource addObject:self.threeButton];
    [self.threeButton addTarget:self action:@selector(allAction:) forControlEvents:(UIControlEventTouchUpInside)];
    
//        self.threeButton.backgroundColor = [UIColor yellowColor];
    [self.view addSubview:self.threeButton];
    
    
    UILabel *threeLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.threeButton.frame.origin.x, oneLabel.frame.origin.y, self.threeButton.frame.size.width, towLabel.frame.size.height)];
//    threeLabel.backgroundColor = [UIColor blueColor];
    threeLabel.text = @"安全健康";
    threeLabel.textAlignment = NSTextAlignmentCenter;
    threeLabel.font = [UIFont systemFontOfSize:14];
    [self.view addSubview:threeLabel];
    
    
}
#pragma mark ----方法的实现
- (void)allAction:(UIButton *)sender{
    
    NSInteger tag = sender.tag;
    NSString *tilteStr;
    if (201 == tag) {
        tilteStr = @"爱的画画";
        NSString *str = [[NSString alloc] initWithFormat:@"%@",Base@"bbsws.do?action=showalltopic&forumcode=XXDD_QDLY_MHTT_ADHH&pageNumber=1"];
        [self theURL:str titleStr:tilteStr];
    }else if (202 == tag){
         tilteStr = @"故事集锦";
        NSString *str = [[NSString alloc] initWithFormat:@"%@",Base@"bbsws.do?action=showalltopic&forumcode=XXDD_QDLY_MHTT_GSH&pageNumber=1"];
        [self theURL:str titleStr:tilteStr];
        
    }else if (203 == tag){
         tilteStr = @"安全健康";
        NSString *str = [[NSString alloc] initWithFormat:@"%@",Base@"bbsws.do?action=showalltopic&forumcode=XXDD_QDLY_MHTT_WAAQ&pageNumber=1"];
        [self theURL:str titleStr:tilteStr];
        
        
    }
        
}
- (void)theURL:(NSString *)str titleStr:(NSString *)titleStr{
    
    WebViewController *web = [WebViewController new];
    web.str = str;
    web.nameTitle = titleStr;
    [self.navigationController pushViewController:web animated:YES];
}

@end
